package com.lwq.designpattern.behavioralPatterns.chainOfResponsibilityPattern;

/**
 * @author liwq
 * @description
 * @date 2021/11/30 10:08
 */
public abstract class Handler {

    // 组长可审批天数
    public static int groupTeamApproveDays = 2;

    // 项目经理可审批天数
    public static int projectManagerApproveDays = 10;

    // 该审批人可审批的天数级别
    public int approveLevel;

    // 下一级别审批人
    private Handler nextHandler;

    public Handler getNextHandler() {
        return nextHandler;
    }

    public void setNextHandler(Handler nextHandler) {
        this.nextHandler = nextHandler;
    }

    // 处理请假审批的方法
    public void handleRequest(int requestDays) {
        // 实际请假天数，超出了该层级权限范围,提交下一级审批
        if (requestDays > this.approveLevel) {
            if (nextHandler != null) {
                nextHandler.handleRequest(requestDays);
            }
            if (nextHandler == null) {
                System.out.println("你还是走吧");
            }

        } else {
            approveComment();
        }

    }

    // 审批意见
    public abstract void approveComment();
}
